package com.example.ymm.modules1.service.impl.hl.ex;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.hl.ex.ExUserResidue;
import com.example.ymm.modules1.mapper.ex.ExUserResidueMapper;
import com.example.ymm.modules1.query.hl.ex.ExUserResidueQueryCriteria;
import com.example.ymm.modules1.service.hl.ex.ExUserResidueService;
import com.example.ymm.util.QueryHelpPlus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
@DS("slave2")
public class ExUserResidueImpl extends BaseServiceImpl<ExUserResidueMapper, ExUserResidue> implements ExUserResidueService {

    @Override
    public TableList<ExUserResidue> list(ExUserResidueQueryCriteria criteria, YmPageDto pageDto) {
        IPage<ExUserResidue> page = new Page<ExUserResidue>(pageDto.getPage(),pageDto.getPageSize());
        QueryWrapper predicate = QueryHelpPlus.getPredicate(ExUserResidue.class, criteria);
        predicate.orderByAsc("create_time");
        baseMapper.selectPage(page, predicate);
        TableList<ExUserResidue> tableList=new TableList(page);
        return tableList;
    }

    public List<ExUserResidue> queryAll(ExUserResidueQueryCriteria criteria) {
        QueryWrapper predicate = QueryHelpPlus.getPredicate(ExUserResidue.class, criteria);
        predicate.orderByAsc("create_time");
        List<ExUserResidue> result =baseMapper.selectList(predicate);
        return result;
    }
}
